package com.losdun.weixin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.losdun.common.annotation.Log;
import com.losdun.common.core.controller.BaseController;
import com.losdun.common.core.domain.AjaxResult;
import com.losdun.common.enums.BusinessType;
import com.losdun.weixin.domain.ShareImage;
import com.losdun.weixin.service.IShareImageService;
import com.losdun.common.utils.poi.ExcelUtil;
import com.losdun.common.core.page.TableDataInfo;

/**
 * 分享图管理Controller
 * 
 * @author swordye
 * @date 2025-08-19
 */
@RestController
@RequestMapping("/weixin/shareImage")
public class ShareImageController extends BaseController
{
    @Autowired
    private IShareImageService shareImageService;

    /**
     * 查询分享图管理列表
     */
    @PreAuthorize("@ss.hasPermi('weixin:shareImage:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShareImage shareImage)
    {
        startPage();
        List<ShareImage> list = shareImageService.selectShareImageList(shareImage);
        return getDataTable(list);
    }

    /**
     * 导出分享图管理列表
     */
    @PreAuthorize("@ss.hasPermi('weixin:shareImage:export')")
    @Log(title = "分享图管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShareImage shareImage)
    {
        List<ShareImage> list = shareImageService.selectShareImageList(shareImage);
        ExcelUtil<ShareImage> util = new ExcelUtil<ShareImage>(ShareImage.class);
        util.exportExcel(response, list, "分享图管理数据");
    }

    /**
     * 获取分享图管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('weixin:shareImage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shareImageService.selectShareImageById(id));
    }

    /**
     * 新增分享图管理
     */
    @PreAuthorize("@ss.hasPermi('weixin:shareImage:add')")
    @Log(title = "分享图管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShareImage shareImage)
    {
        return toAjax(shareImageService.insertShareImage(shareImage));
    }

    /**
     * 修改分享图管理
     */
    @PreAuthorize("@ss.hasPermi('weixin:shareImage:edit')")
    @Log(title = "分享图管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShareImage shareImage)
    {
        return toAjax(shareImageService.updateShareImage(shareImage));
    }

    /**
     * 删除分享图管理
     */
    @PreAuthorize("@ss.hasPermi('weixin:shareImage:remove')")
    @Log(title = "分享图管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shareImageService.deleteShareImageByIds(ids));
    }
}
